
/**
 * 将数据转字符串格式
 * @param {*} obj 要转字符串的数据
 */
const dataToStr = obj => {
    let str = ''
    if (typeof obj === 'string') {
        str += `'${obj}'`
    } else if (typeof obj === 'number') {
        str += obj
    } else if (typeof obj === 'function') {
        evalStr += obj.name
    } else if (typeof obj === 'object') {
        if (obj instanceof Array) {
            str += '['
        } else {
            str += '{'
        }
        for (let i in obj) {
            if (!(obj instanceof Array)) {
                str += `${i}:`
            }
            str += `${dataToStr(obj[i])},`
        }
        str = str.substr(0, str.length - 1)
        if (obj instanceof Array) {
            str += ']'
        } else {
            str += '}'
        }
    }
    return str
}

export {
    dataToStr
}